package com.subang.function.service.impl;

import java.util.List;
import com.subang.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.subang.function.mapper.SbArticleMapper;
import com.subang.function.domain.SbArticle;
import com.subang.function.service.ISbArticleService;

/**
 * 文章Service业务层处理
 * 
 * @author subei
 * @date 2025-03-13
 */
@Service
public class SbArticleServiceImpl implements ISbArticleService 
{
    @Autowired
    private SbArticleMapper sbArticleMapper;

    /**
     * 查询文章
     * 
     * @param id 文章主键
     * @return 文章
     */
    @Override
    public SbArticle selectSbArticleById(Long id)
    {
        sbArticleMapper.addOneViews(id);
        return sbArticleMapper.selectSbArticleById(id);
    }

    /**
     * 查询文章列表
     * 
     * @param sbArticle 文章
     * @return 文章
     */
    @Override
    public List<SbArticle> selectSbArticleList(SbArticle sbArticle)
    {
        return sbArticleMapper.selectSbArticleList(sbArticle);
    }

    /**
     * 新增文章
     * 
     * @param sbArticle 文章
     * @return 结果
     */
    @Override
    public int insertSbArticle(SbArticle sbArticle)
    {
        sbArticle.setCreateTime(DateUtils.getNowDate());
        return sbArticleMapper.insertSbArticle(sbArticle);
    }

    /**
     * 修改文章
     * 
     * @param sbArticle 文章
     * @return 结果
     */
    @Override
    public int updateSbArticle(SbArticle sbArticle)
    {
        sbArticle.setUpdateTime(DateUtils.getNowDate());
        return sbArticleMapper.updateSbArticle(sbArticle);
    }

    /**
     * 批量删除文章
     * 
     * @param ids 需要删除的文章主键
     * @return 结果
     */
    @Override
    public int deleteSbArticleByIds(Long[] ids)
    {
        return sbArticleMapper.deleteSbArticleByIds(ids);
    }

    /**
     * 删除文章信息
     * 
     * @param id 文章主键
     * @return 结果
     */
    @Override
    public int deleteSbArticleById(Long id)
    {
        return sbArticleMapper.deleteSbArticleById(id);
    }

    @Override
    public List<SbArticle> selectSbArticleListOrderByCreateTime(SbArticle sbArticle) {
        return sbArticleMapper.selectSbArticleListOrderByCreateTime(sbArticle);
    }

    @Override
    public List<SbArticle> selectSbArticleListOrderByViewCount(SbArticle sbArticle) {
        return sbArticleMapper.selectSbArticleListOrderByViewCount(sbArticle);
    }

    @Override
    public List<SbArticle> selectSbArticleListByIds(List<Long> ids) {
        return sbArticleMapper.selectSbArticleListByIds(ids);
    }
}
